<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>htmlcss 阶段</title>
    <style>
        .container {
            width: 1000px;
            height: 300px;
            background-color: #ccc;
            overflow: hidden;
            margin: 0 auto;
            display: flex;
            align-items: center;
        }

        .container>div {
            border-radius: 50%;
            border: 1px solid #fff;
            background-color: rgba(255, 0, 0, 1);
            flex-shrink: 0;
        }
    </style>
</head>

<body>
    <div class="container">
        <div></div>
    </div>


    <script>
        // // 要求：
        //     编写函数 createCircle ，创建标签并添加到.container标签内
        //     创建的标签，尺寸（w,h）初始化值为 40, 透明度(a)为1
        //     然后每调用一次函数后，创建的标签的尺寸自增10px ,透明度减去 0.08

        // function createCircle(option) {
        //     var container = document.querySelector(".container");
        //     var ele = document.createElement("div");
        //     for (var key in option) {
        //         ele.style[key] = option[key];
        //     }
        //     container.appendChild(ele);
        // }
        // for (var i = 0; i < 12; i++) {
        //     createCircle({ width: (40 + i * 10) + "px", height: (40 + i * 10) + "px", opacity: (1 - 0.08 * i) });
        // }
        //  createCircle();

        function CreateCircle() {
            this.w = 40;
            this.h = 40;
            this.a = 1;
            // var container = document.querySelector(".container");
            // var ele = document.createElement("div");
            // ele.style["width"] = this.w + "px";
            // ele.style["height"] = this.h + "px";
            // ele.style["opacity"] = this.a + "px";
            
        }

        CreateCircle.prototype.hanshu = function () {
            for (i = 0; i < 11; i++) {
                this.w = 40 + i * 10;
                this.h = 40 + i * 10;
                this.a = 1 - i * 0.08;
                var container = document.querySelector(".container");
                var ele = document.createElement("div");
                ele.style["width"] = this.w + "px";
                ele.style["height"] = this.h + "px";
                ele.style["opacity"] = this.a;
                container.appendChild(ele);
            }
        }

        var d = new CreateCircle();
        d.hanshu();
    </script>
</body>

</html>